#include <bits/stdc++.h>
using namespace std;

class MyQueue {
private:
    stack<int> stk1, stk2;
public:
    MyQueue() {
        
    }
    
    void push(int x) {
        stk1.push(x);
    }
    
    int pop() {
        if(stk2.empty()) {
            while(!stk1.empty()){
                stk2.push(stk1.top());
                stk1.pop();
            }
        }
        int t = stk2.top();
        stk2.pop();
        return t;
    }
    
    int peek() {
        if(stk2.empty()) {
            while(!stk1.empty()){
                stk2.push(stk1.top());
                stk1.pop();
            }
        }
        int t = stk2.top();
        return t;
    }
    
    bool empty() {
        return stk1.empty()&&stk2.empty();
    }
};